package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.CategoryDTO;
import com.sky.dto.CategoryPageQueryDTO;
import com.sky.entity.Category;
import com.sky.result.Result;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;


@Mapper
public interface CategoryMapper {

//    根据用户名查询员工
    @Select("select * from employee where username = #{username}")
    Category getByName(String username);
    @Insert("insert into category(type, name, sort, status, create_time, update_time, create_user, update_user)" +
            " VALUES(#{type}, #{name}, #{sort}, #{status}, #{createTime}, #{updateTime}, #{createUser}, #{updateUser})")
    void insert(Category category);

    /**
     * 分页查询
     *
     * @param dto
     * @return
     */
    Page<Category> page(CategoryPageQueryDTO dto);

    /**
     * 启用状态和修改数据
     * @param category
     */
    void updateStatus(Category category);

    /**
     * 删除分类管理
     * @param dto
     */
    @Delete("delete from category where id=#{id};")
    void deleteById(Category dto);
    /**
     * 根据类型查询分类
     * @param
     * @return
     */
    List<Category> list(Integer type);

}
